<script type="text/javascript">

function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
}
let a = new TreeNode(1);
let b = new TreeNode(2);
let c = new TreeNode(3);
let d = new TreeNode(4);
let e = new TreeNode(5);
let f = new TreeNode(6);
let g = new TreeNode(7);
a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;
	
function ForTree(root) {
	if(!root) return null;
	// console.log(root.val);		// 先序遍历
	ForTree(root.left);
	// console.log(root.val);		// 中序遍历
	ForTree(root.right);
	console.log(root.val);		// 后续遍历
}

ForTree(a);

</script>